package dw.catalog

import grails.rest.Resource
import dw.content.MediaFile
import dw.object.ExtensibleObject

/**
 * Represents a category in a product catalog.
 */
class Category extends ExtensibleObject {

	Collection		allRecommendations,
					categoryAssignments,
					incomingCategoryLinks,
					onlineCategoryAssignments,
					onlineIncomingCategoryLinks,
					onlineOutgoingCategoryLinks,
					onlineProducts,
					onlineSubCategories,
					orderableRecommendations,
					outgoingCategoryLinks,
					products,
					recommendations,
					subCategories
					
	SortingRule 	defaultSortingRule
	
	String			description,
					displayName,
					ID,
					pageDescription,
					pageKeywords,
					pageTitle,
					pageURL,
					siteMapChangeFrequency,
					template
					
	MediaFile		image,
					thumbnail
	
	Boolean			online,
					onlineFlag,
					root,
					topLevel
					
	Date			onlineTo
	
	Category		parent
	
	ProductAttributeModel	productAttributeModel
	
	Number					searchPlacement,
							searchRank,
							siteMapPriority
											
	
    static constraints = {
		allRecommendations(nullable: true)
		categoryAssignments(nullable: true)
		incomingCategoryLinks(nullable: true)
		onlineCategoryAssignments(nullable: true)
		onlineIncomingCategoryLinks(nullable: true)
		onlineOutgoingCategoryLinks(nullable: true)
		onlineProducts(nullable: true)
		onlineSubCategories(nullable: true)
		orderableRecommendations(nullable: true)
		outgoingCategoryLinks(nullable: true)
		products(nullable: true)
		recommendations(nullable: true)
		subCategories(nullable: true)
		
		defaultSortingRule(nullable: true)
		
		description(nullable: true)
		displayName(nullable: true)
		ID(nullable: false, blank: false)
		pageDescription(nullable: true)
		pageKeywords(nullable: true)
		pageTitle(nullable: true)
		pageURL(nullable: true)
		siteMapChangeFrequency(nullable: true)
		template(nullable: true)
		
		image(nullable: true)
		thumbnail(nullable: true)
		
		online(nullable: true)
		onlineFlag(nullable: true)
		root(nullable: true)
		topLevel(nullable: true)
		
		onlineTo(nullable: true)
		
		parent(nullable: true)
		
		productAttributeModel(nullable: true)
		
		searchPlacement(nullable: true)
		searchRank(nullable: true)
		siteMapPriority(nullable: true)
    }
	
	static hasMany = [allCategories: Category, categories: Category, onlineCategories: Category]
	
	static mapping = {
		id generator: "uuid", name: "UUID", column: "UUID", unique:"true"
	}
}
